package com.stylefeng.guns.modular.system.controller;

import com.stylefeng.guns.core.base.controller.BaseController;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.beans.factory.annotation.Autowired;
import com.stylefeng.guns.core.log.LogObjectHolder;
import org.springframework.web.bind.annotation.RequestParam;
import com.stylefeng.guns.modular.system.model.NbGpcWt;
import com.stylefeng.guns.modular.system.service.INbGpcWtService;

/**
 * 委托控制器
 *
 * @author fengshuonan
 * @Date 2018-08-30 17:39:23
 */
@Controller
@RequestMapping("/nbGpcWt")
public class NbGpcWtController extends BaseController {

    private String PREFIX = "/system/nbGpcWt/";

    @Autowired
    private INbGpcWtService nbGpcWtService;

    /**
     * 跳转到委托首页
     */
    @RequestMapping("")
    public String index() {
        return PREFIX + "nbGpcWt.html";
    }

    /**
     * 跳转到添加委托
     */
    @RequestMapping("/nbGpcWt_add")
    public String nbGpcWtAdd() {
        return PREFIX + "nbGpcWt_add.html";
    }

    /**
     * 跳转到修改委托
     */
    @RequestMapping("/nbGpcWt_update/{nbGpcWtId}")
    public String nbGpcWtUpdate(@PathVariable Integer nbGpcWtId, Model model) {
        NbGpcWt nbGpcWt = nbGpcWtService.selectById(nbGpcWtId);
        model.addAttribute("item",nbGpcWt);
        LogObjectHolder.me().set(nbGpcWt);
        return PREFIX + "nbGpcWt_edit.html";
    }

    /**
     * 获取委托列表
     */
    @RequestMapping(value = "/list")
    @ResponseBody
    public Object list(String condition) {
        return nbGpcWtService.selectList(null);
    }

    /**
     * 新增委托
     */
    @RequestMapping(value = "/add")
    @ResponseBody
    public Object add(NbGpcWt nbGpcWt) {
        nbGpcWtService.insert(nbGpcWt);
        return SUCCESS_TIP;
    }

    /**
     * 删除委托
     */
    @RequestMapping(value = "/delete")
    @ResponseBody
    public Object delete(@RequestParam Integer nbGpcWtId) {
        nbGpcWtService.deleteById(nbGpcWtId);
        return SUCCESS_TIP;
    }

    /**
     * 修改委托
     */
    @RequestMapping(value = "/update")
    @ResponseBody
    public Object update(NbGpcWt nbGpcWt) {
        nbGpcWtService.updateById(nbGpcWt);
        return SUCCESS_TIP;
    }

    /**
     * 委托详情
     */
    @RequestMapping(value = "/detail/{nbGpcWtId}")
    @ResponseBody
    public Object detail(@PathVariable("nbGpcWtId") Integer nbGpcWtId) {
        return nbGpcWtService.selectById(nbGpcWtId);
    }
}
